VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



All About Beep API [Article

by MadWizardBD (1 Submission)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (13 Votes)

U may assume that Beep API can only be used 4 beeping. But, wait there's more what you can do with this API. You can also drive the mosquitos away using this technique! Check it out now! AND NEVER FORGET TO RATE!!

Rate All About Beep API [Article

 


All About 
Beep API


Introduction

Today we will discuss about the Beep API which is very simple to use. 
You may think that what the Beep API can do without beeping. But, wait there's 
more what you can do with this API. You can also drive the mosquitos away using 
this technique! Let's have a look at them.



The Beep API

The function is synchronous, so it doesn't return control to its caller 
until the sound finishes. Actually if you have Win9x OS such as Windows95/98/ME, 
there is nothing more you can do than beeping with this API. So, it would be 
better if you use the built-in VB command 'beep' instead of using Beep API. You 
can generate 37Hz to 32768Hz (inclusive) frequency on WinNT/2000/XP and it is up 
to you how long your VB program will generate this frequency using your PC 
Speaker. Let's take a look at this one of the simpliest APIs use...


Private Declare Function Beep Lib "kernel32" Alias "Beep" (ByVal _
dwFreq As Long, ByVal dwDuration As Long) As Long





Private Sub Form_Load()

'36 < Frequency < 32768 and Duration in miliseconds.

' here we are using Frequency=11000 and Duration = 1000

'so set the variable



Freq=11000

Duration=1000

ai = Beep(Freq,Duration)


'if success ai <> 0



End Sub



In this code, first we have declared the Beep API and set the arguments to pass. 
The first argument it takes is dwFreq, and the last one is dwDuration. As we 
would like to generate 11KHz of frequency for 1 second. We've just simply set 
variable to pass. Here you should remember that the dwDuration argument is in 
miliseconds. So, if you set this to 1000, it will generate sound for 1 second. 
So, you can also drive the mosquitos away using this technique!



Conclusion

And this is exactly all about. Hope I'll introduce you with few good 
stuffs in VB programming. Never forget to contact me for any question, comments 
regarding Win32 API, VB, Java etc. Contact me without hesitation. My email 
address is [email protected]. I'll be happy to help you. LET ME KNOW WHAT 
DO YOU THINK!!! AND NEVER FORGET TO RATE!!


Download this snippet    Add to My Saved Code

All About Beep API [Article Comments

No comments have been posted about All About Beep API [Article. Why not be the first to post a comment about All About Beep API [Article.

Post your comment

Subject:
Message:
0/1000 characters